A buffer is a section of memory used as a work area.
BufferedWriter
StreamDisk input and output is more efficient when a buffer is used. For our small example programs it doesn't matter much. However, programs that do extensive IO should use buffers. The BufferedWriter stream is used for this with a character output stream.
BufferedWriter(Writer out) Construct a buffered character-output stream
The constructor is used as follows.
Since FileWrite
is a Writer
it is the correct type for the parameter.
BufferedWriter out = new BufferedWriter(new FileWriter("stuff.txt"));
Different operating systems separate lines of text in different ways. To the annoyance of programmers everywhere, Microsoft operating systems use a two byte sequence at the end of a line of text, but Unix (and Linux) operating systems use just one byte.